#include "utils.h"
#include <QTime>

void debug(const QString& s)
{
#ifndef __DEBUG__
    Q_UNUSED(s);
#endif
#ifdef __DEBUG__
    qDebug() << s;
#endif
}

bool ip2ByteLen4(const QString &s, byte *ba)
{
    QHostAddress host(s);
    if(host.isNull()){
        return false;
    }
    QStringList part4 = s.split(".");
    if(part4.length() != 4){
        return false;
    }
    for(int i =0;i<4;++i){
        const QString &item = part4.at(i);
        bool isOK = false;
        int v = item.toShort(&isOK,10);
        if(isOK){
            *(ba + i) = (byte)v;    
        }
    }
    return true;
}

QString currentTime()
{
    return QTime::currentTime().toString("HH:mm:ss");
}
